package com.self.common.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.self.common.mapper.ConfigMapper;
import com.self.common.service.ConfigService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import com.self.common.model.Config;


@Service
public class ConfigServiceImpl extends ServiceImpl<ConfigMapper, Config> implements ConfigService {

    @Override
    public Page<Config> findByPage(Page<Config> page, String type, String name, String code) {
        return page(page,new LambdaQueryWrapper<Config>()
                                .eq(StringUtils.hasText(type), Config::getType,type)
                                .like(StringUtils.hasText(name),Config::getName,name)
                                .likeRight(StringUtils.hasText(code),Config::getCode,code)
                                );
    }

    @Override
    public Config findByCode(String code) {
        return getOne(new LambdaQueryWrapper<Config>().eq(Config::getCode,code));
    }
}
